from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC


class BankCardGenerator:

    def generate_identity_no(self):
        self.browser = webdriver.Firefox()
        self.browser.get('file:///C:/Users/Administrator/Desktop/%E6%95%B0%E6%8D%AE%E7%94%9F%E6%88%90%E5%99%A8.html')
        EC.element_to_be_clickable(self.browser.find_element_by_name('btncreate1'))
        self.browser.find_element_by_name('btncreate1').click()
        id_card = self.browser.find_element_by_css_selector('#info1 > font').text
        self.browser.quit()
        print('生成身份证号：'+id_card)
        return id_card

    def generate_bank_card_no(self):
        self.browser = webdriver.Firefox()
        self.browser.get('file:///C:/Users/Administrator/Desktop/%E6%95%B0%E6%8D%AE%E7%94%9F%E6%88%90%E5%99%A8.html')
        EC.element_to_be_clickable(self.browser.find_element_by_name('btncreate'))
        self.browser.find_element_by_name('btncreate').click()
        bank_no = self.browser.find_element_by_css_selector('#info > font').text
        self.browser.quit()
        print('生成银行卡号:'+bank_no)
        return bank_no

if __name__ == '__main__':
    gen = BankCardGenerator()
    identity_no = gen.generate_identity_no()
    bank_card_no = gen.generate_bank_card_no()
    print(identity_no)
    print(bank_card_no)